package com.buybuyyi.stylistcrm.user.mapper;

import com.buybuyyi.stylistcrm.user.po.UserRequisition;
import com.buybuyyi.stylistcrm.user.po.UserRequisitionWithBLOBs;
import org.apache.ibatis.annotations.Param;
import stylistcrm.core.services.order.exception.BizException;
import stylistcrm.core.services.user.requisition.EnumRequisitionState;
import stylistcrm.core.services.user.requisition.QueryRequisitionConditionDto;

import java.util.List;

public interface UserRequisitionMapper {
    int deleteByPrimaryKey(Long id);

    int insert(UserRequisitionWithBLOBs record);

    int insertSelective(UserRequisitionWithBLOBs record);

    UserRequisitionWithBLOBs selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(UserRequisitionWithBLOBs record);

    int updateByPrimaryKeyWithBLOBs(UserRequisitionWithBLOBs record);

    int updateByPrimaryKey(UserRequisition record);

    /**
     * 翻页查询用户申请单
     * @param queryCondition
     * @return
     */
    List<UserRequisitionWithBLOBs> queryByPage(QueryRequisitionConditionDto queryCondition);

    /**
     * 按条件查询总数据
     * @param queryCondition
     * @return
     * @throws BizException
     */
    Integer queryTotalCount( QueryRequisitionConditionDto queryCondition);

    /**
     * 更新申请状态
     * @param pkId 编号
     * @param state 状态
     * @return true更新成功，false更新失败
     */
    boolean updateRequisitionState(@Param("pkId") Long pkId, @Param("state") EnumRequisitionState state);

    /**
     * 查询用户申请的单
     * @param secUserId
     * @return
     */
    List<UserRequisitionWithBLOBs> queryByUserId(Long secUserId);

    /**
     * 查询用户申请的单
     * @param secUserId
     * @return
     */
    List<UserRequisitionWithBLOBs> queryByUserIdAndState(@Param("pkId") Long secUserId,@Param("state") EnumRequisitionState state);

    /**
     * 通过主键id获取对象（包含用户登录名）
     * @param pkId
     * @return
     */
    List<UserRequisitionWithBLOBs> queryByPkId(Long pkId);
}